<?php

namespace App\Mail;

use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class ConfirmEmail extends Mailable
{
    use Queueable, SerializesModels;

    public $user;

    /**
     * Create a new message instance.
     *
     * @param User $user
     */
    public function __construct(User $user)
    {
        $this->user = $user;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {

        $from = 'onnext@126.com';
        $to = $this->user->email;
        $view = 'emails.confirm';
        $subject = "感谢您注册Laravel,请您确认您的邮箱";
        return $this->from($from)->to($to)->subject($subject)->view($view,compact($this->user));
    }
}
